﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using DCSLibrary;
using Telerik.Web.UI;
using Utils.DC.Web.UI;

public partial class Admin_Module_quan_tri_nhom_san_pham : System.Web.UI.UserControl
{
    #region Cac bien dung chung
    CategoryPageUI objPage = new CategoryPageUI();
    DataSet dsPage;

    #endregion

    #region Cac Ham Su Kien

    protected void Page_Load(object sender, EventArgs e)
    {
        dsPage = objPage.GetAll();
        SqlDataSource1.ConnectionString = Utils.Common.Conn;
        SqlDataSource2.ConnectionString = Utils.Common.Conn;
    }

    protected void Page_Delete(object sender, GridCommandEventArgs e)
    {
        try
        {
            int id = Convert.ToInt32((e.Item as GridDataItem).OwnerTableView.Items[e.Item.ItemIndex]["FunctionPageID"].Text.ToString());
            int result = objPage.DeleteByID(id);
            if (result > 0)
            {
                //Response.Write(messageBox.Alert(MessageBox.MESSAGE_ADD_SUCCESSFULLY));
                lblMessage.Text = MessageBox.MESSAGE_DELETE_SUCCESSFULLY;
                BindGrid();
            }
            else
            {
                //Response.Write(messageBox.Alert(MessageBox.MESSAGE_ADD_NOT_SUCCESSFULLY));
                lblMessage.Text = MessageBox.MESSAGE_DELETE_NOT_SUCCESSFULLY;
            }
        }
        catch (Exception ex)
        {
            lblMessage.Text = MessageBox.MESSAGE_CONFILCT_DATA;
        }
    }

    protected void Ajax_Request(object sender, AjaxRequestEventArgs e)
    {
        if (e.Argument == "Rebind")
        {
            BindGrid();
        }
    }

    #endregion

    #region Cac Ham Tuong Tac Du Lieu

    private void BindGrid()
    {
        grdPage.Rebind();
    }


    #endregion
}
